package com.dofast.bt.mvp.view.activity.my;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.content.Loader;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dofast.bt.R;
import com.dofast.bt.base.BaseMvpActivity;
import com.dofast.bt.mvp.presenter.my.MyOrderListPresenter;
import com.dofast.bt.util.PresenterFactory;
import com.dofast.bt.util.PresenterLoder;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * username:Created by hsj on 2016/12/22 0022.
 * class：
 * 类描述：
 */

public class MyOrderListActivity extends BaseMvpActivity<MyOrderListPresenter, MyOrderListView> implements MyOrderListView {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_edit)
    TextView tvEdit;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_one)
    TextView tvOne;
    @BindView(R.id.v_one)
    View vOne;
    @BindView(R.id.ll_one)
    LinearLayout llOne;
    @BindView(R.id.tv_two)
    TextView tvTwo;
    @BindView(R.id.v_two)
    View vTwo;
    @BindView(R.id.ll_two)
    LinearLayout llTwo;
    @BindView(R.id.tv_three)
    TextView tvThree;
    @BindView(R.id.v_three)
    View vThree;
    @BindView(R.id.ll_three)
    LinearLayout llThree;
    @BindView(R.id.tv_four)
    TextView tvFour;
    @BindView(R.id.v_four)
    View vFour;
    @BindView(R.id.ll_four)
    LinearLayout llFour;
    @BindView(R.id.tv_five)
    TextView tvFive;
    @BindView(R.id.v_five)
    View vFive;
    @BindView(R.id.ll_five)
    LinearLayout llFive;

    @Override
    protected int getResourcesId() {
        return R.layout.activity_my_order;
    }

    @Override
    protected void initView() {
        initTitle();
    }

    @Override
    protected void addOnClickListener() {

    }

    @Override
    public Loader<MyOrderListPresenter> onCreateLoader(int id, Bundle args) {
        return new PresenterLoder<>(this, new PresenterFactory<MyOrderListPresenter>() {
            @Override
            public MyOrderListPresenter create() {
                return new MyOrderListPresenter();
            }
        });
    }

    private void hidtItem() {
        tvOne.setTextColor(Color.rgb(123, 123, 123));
        tvTwo.setTextColor(Color.rgb(123, 123, 123));
        tvThree.setTextColor(Color.rgb(123, 123, 123));
        tvFour.setTextColor(Color.rgb(123, 123, 123));
        tvFive.setTextColor(Color.rgb(123, 123, 123));
        vOne.setVisibility(View.GONE);
        vTwo.setVisibility(View.GONE);
        vThree.setVisibility(View.GONE);
        vFour.setVisibility(View.GONE);
        vFive.setVisibility(View.GONE);
    }

    @Override
    public void showItem1() {
        hidtItem();
        tvOne.setTextColor(Color.rgb(56, 56, 56));
        vOne.setVisibility(View.VISIBLE);
    }

    @Override
    public void showItem2() {
        hidtItem();
        tvTwo.setTextColor(Color.rgb(56, 56, 56));
        vTwo.setVisibility(View.VISIBLE);
    }

    @Override
    public void showItem3() {
        hidtItem();
        tvThree.setTextColor(Color.rgb(56, 56, 56));
        vThree.setVisibility(View.VISIBLE);
    }

    @Override
    public void showItem4() {
        hidtItem();
        tvFour.setTextColor(Color.rgb(56, 56, 56));
        vFour.setVisibility(View.VISIBLE);
    }

    @Override
    public void showItem5() {
        hidtItem();
        tvFive.setTextColor(Color.rgb(56, 56, 56));
        vFive.setVisibility(View.VISIBLE);
    }

    @Override
    public void initTitle() {
        tvTitle.setText("我的订单");
        tvEdit.setVisibility(View.GONE);
        ivBack.setVisibility(View.VISIBLE);
    }

    @Override
    public void gotoActivity(Class<?> tClass, boolean isFinish) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.iv_back, R.id.ll_one, R.id.ll_two, R.id.ll_three, R.id.ll_four, R.id.ll_five})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.ll_one:
                presenter.itemClick1();
                break;
            case R.id.ll_two:
                presenter.itemClick2();
                break;
            case R.id.ll_three:
                presenter.itemClick3();
                break;
            case R.id.ll_four:
                presenter.itemClick4();
                break;
            case R.id.ll_five:
                presenter.itemClick5();
                break;
        }
    }
}
